var langList ;
var MOVIE_TIME_PATH = "/usr/data/movie_time";
function init(){
	document.cachePage = false;
	
	langList = new Array();
	langList.push({val:'lang_en',name:'English',target:'default'});
	langList.push({val:'lang_ina',name:'Bahasa',target:'default'});
	//initData(afterInitData);
	afterInitData({});
}

function afterInitData(data){
	if(!data){
		showGTip('Load Data Fail. ');
		return false;
	}
	
	/*
	if(data.customerId != config.customerId){		//如果顾客ID不同
		config.newLang='lang_en';
		mSTB.removeSpeFile(MOVIE_TIME_PATH);
		$.setConfigValue('customerId',data.customerId+''); 
	}
	*/
	
	var main = document.getElementById('main');
	main.style.display = 'block';
	var con = '&nbsp;';
	/*
	con += '<div class="title">Hello:'+data.customerName+'</div>';
	con += '<div class="li">Welcome our hotel</div>';
	con += ' <div class="li">Number:'+data.roomNumber+'</div>';
	con += '<div class="li">tel:'+data.tel+'</div>';
	con += '<div class="li">Amount:'+data.amount+'</div>';
	*/
	var conLeft = document.getElementById('conLeft');
	conLeft.innerHTML = con;
	
	con = '';
	var curLangId = 1,lang,j;
	for(var i = 0;i<langList.length;i++){
		lang = langList[i];
		j = i + 1;
		con+='<div class="item"><a href="#" id="item-a-'+j+'">'+lang.name+'</a></div>';
		if(lang.val == config.newLang){
			curLangId = j;
		}
	}
	var box = document.getElementById('box');
	box.innerHTML = con;
	
	var aList = box.getElementsByTagName('a');
	var a;
	
	for(var i = 0;i<aList.length;i++){
		a = aList[i];
		a.onfocus = focusItem;
		a.onblur = blurItem;
		a.onclick = clickItem;
	}
	aList[curLangId - 1].focus();
}

function focusItem(event){
	var a = event.currentTarget;
	var par = a.parentNode;
	par.className = 'curItem';
}
function blurItem(event){
	var a = event.currentTarget;
	var par = a.parentNode;
	par.className = 'item';
}

function clickItem(event){
	var a = event.currentTarget;
	var idArray = a.id.split('-');
	var tar = parseInt(idArray[2]);
	var data = langList[tar - 1];
	
	$.setConfigValue('newLang',data.val); 
	document.clearCachePage();
	$.gotoPage('index2.html');
}